﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace CandidateRank
{
    public partial class Form1 : Form
    {
        private System.Windows.Forms.Label lblInfo;
        private int removedNodes;
        private Rectangle screenRec;
        private System.Windows.Forms.TreeView tvDOM;
        private System.Windows.Forms.TreeView tvReducer;
        

        public Form1()
        {
            InitializeComponent();
        }


        //private void Browser_DocumentComplete(object sender, AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e)
        //{
            //HTMLSplit.HTMLBlock block;
            //TreeNode tn, curNode;
            //CodeCompare cc = new CodeCompare();
            //int index;
            ////System.DateTime mTime;


            //if (e.pDisp.Equals(PageToken))
            //{

            //    txtUrl.Text = e.uRL.ToString();

            //    //WebClient w = new WebClient();
            //    //byte[] bytes = w.DownloadData(txtUrl.Text);
            //    //string strHtml = System.Text.Encoding.Default.GetString(bytes);

            //    //HTMLDocumentClass hc = new HTMLDocumentClass();
            //    //IHTMLDocument2 doc = hc;

            //    //doc.write(strHtml);
            //    //doc.close();

            //    //blockList = HTMLSplit.Global.HTMLToBlock((mshtml.HTMLDocument)doc);

            //    //AQI~
            //    //对于多frame文件，会有多个blocklist，
            //    mshtml.HTMLDocument doc = ((mshtml.HTMLDocument)Browser.Document);

            //    for (int i = 0; i < doc.parentWindow.frames.length; i++)
            //    {
            //        object j;
            //        j = i;
            //        HTMLWindow2Class frame = doc.parentWindow.frames.item(ref j) as HTMLWindow2Class;

            //    }
            //    //AQI~

            //    blockList = HTMLSplit.Global.HTMLToBlock((mshtml.HTMLDocument)Browser.Document);



            //    //HTMLDocument hc = new HTMLDocument();


            //    // IHTMLDocument2 doc =(IHTMLDocument2)( (IHTMLDocument4)hc.createDocumentFromUrl("http://www.google.com", "null"));

            //    // while (doc.readyState != "complete")
            //    // {
            //    //     Thread.Sleep(0);
            //    // }


            //    //string requestURL = "http://www.google.com";
            //    //HTMLDocument ProfileHTML = new HTMLDocument();
            //    //IHTMLDocument2 ProfileHTML2;
            //    //((IHTMLDocument2)ProfileHTML).write("<html></html>");
            //    //((IHTMLDocument2)ProfileHTML).close();
            //    //ProfileHTML2 = ((IHTMLDocument4)ProfileHTML).createDocumentFromUrl(requestURL, "null");
            //    //while(ProfileHTML2.readyState != "complete")
            //    //{
            //    //    Thread.Sleep(100);
            //    //}




            //    //blockList = HTMLSplit.Global.HTMLToBlock((mshtml.HTMLDocument)doc);

            //    //给页面的每个元素添加边框
            //    //PageAddBoder((mshtml.HTMLDocument)Browser.Document);

            //    block = (HTMLSplit.HTMLBlock)blockList[0];

            //    screenRec = new Rectangle();
            //    screenRec = block.Rect;
            //    screenRec.Size = block.Size;


            //    tvDOM.Nodes.Clear();
            //    tvDOM.BeginUpdate();
            //    for (int i = 0; i < blockList.Count; i++)
            //    {
            //        block = (HTMLSplit.HTMLBlock)blockList[i];
            //        tn = new TreeNode(block.TagName);
            //        tn.Tag = block;

            //        if (block.blockCode.Length == 3)
            //        {
            //            tvDOM.Nodes.Add(tn);
            //        }
            //        else
            //        {
            //            curNode = tvDOM.Nodes[0];
            //            for (int j = 1; j < block.blockCode.Length / 3 - 1; j++)
            //            {
            //                index = System.Convert.ToInt32(block.blockCode.Substring(j * 3, 3)) - 1;
            //                curNode = curNode.Nodes[index];
            //            }
            //            curNode.Nodes.Add(tn);
            //        }
            //    }
            //    tvDOM.EndUpdate();

            //    tvReducer.Nodes.Clear();
            //    tvReducer.BeginUpdate();
            //    tvReducer.Nodes.Add((TreeNode)tvDOM.Nodes[0].Clone());
            //    tvReducer.EndUpdate();

            //    if (plTopology.Width < getTreeNodeRec(tvDOM.Nodes[0]).Width)
            //        plTopology.Width = getTreeNodeRec(tvDOM.Nodes[0]).Width + 100;
            //    if (plTopology.Height < getTreeNodeRec(tvDOM.Nodes[0]).Height)
            //        plTopology.Height = getTreeNodeRec(tvDOM.Nodes[0]).Height + 100;
            //    plTopology.Invalidate();

            //    plReducer.Height = plTopology.Height;
            //    plReducer.Width = plTopology.Width;
            //    blockQueue = new Queue();

            //    factRec = getTreeNodeRec(tvDOM.Nodes[0]);
            //    //直接装到生成CRF训练集的页面
            //    tabMain.SelectedIndex = 3;

            //    selectListForAnnotation();
            //    //newsextract();

            //    //mTime=new System.DateTime();
            //    //excuteRules();

            //    //findRecords(tvDOM.Nodes[0]);
            //}
        //}

        //private void Browser_BeforeNavigate2(object sender, AxSHDocVw.DWebBrowserEvents2_BeforeNavigate2Event e)
        //{
        //    //if (PageToken == null)
        //    //{
        //    //    PageToken = e.pDisp;
        //    //}
        //}

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            String urltmp = textBox1.Text;
            axWebBrowser1.Navigate(urltmp);
        }


    }
}